package com.company.oa.announcement.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.company.oa.announcement.entity.AnnouncementRead;
import com.company.oa.announcement.service.AnnouncementReadService;
import com.company.oa.common.api.Result;
import com.company.oa.security.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/announcement-reads")
public class AnnouncementReadController {

    @Autowired
    private AnnouncementReadService readService;

    /**
     * 获取公告阅读记录
     */
    @GetMapping("/page/{announcementId}")
    @RequiresPermissions("announcement:read:list")
    public Result<IPage<AnnouncementRead>> getReadRecordPage(
            @PathVariable Long announcementId,
            @RequestParam(defaultValue = "1") int page,
            @RequestParam(defaultValue = "10") int size) {
        IPage<AnnouncementRead> pageResult = readService.getReadRecordPage(page, size, announcementId);
        return Result.success(pageResult);
    }
}